package com.zoweunion.mechanic.controller;

import com.github.pagehelper.PageInfo;
import com.zoweunion.mechanic.model.ResponseBean;
import com.zoweunion.mechanic.service.EngineServerService;
import com.zoweunion.mechanic.service.FacilitatorPersonnelRelationService;
import com.zoweunion.mechanic.util.MyException;
import com.zoweunion.mechanic.util.constants.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


/**
 * 主机厂服务商
 *
 * @author xp
 * @email 17688825585@163.com
 * @date 2020-08-28 13:34:07
 */
@RestController
@RequestMapping("/engineServer")
public class EngineServerController extends BaseController {

    @Autowired
    private FacilitatorPersonnelRelationService relationService;
    @Autowired
    private EngineServerService engineServerService;

    /**
     * 服务商列表
     */
    @GetMapping("/serverLists")
    public ResponseBean serverLists(@RequestParam Map<String, Object> params, HttpServletRequest request)  throws MyException {
        List<Map<String,Object>> serverList = engineServerService.selectServerList(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", serverList);
    }

    /**
     * 服务商详情
     */
    @GetMapping("/serverInfoList")
    public ResponseBean serverInfoList(@RequestParam Map<String, Object> params, HttpServletRequest request)  throws MyException {
        Map<String, Object> serverInfoList = engineServerService.selectServerInfoList(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", serverInfoList);
    }

    /**
     * 服务商车辆列表
     */
    @GetMapping("/serverThingsList")
    public ResponseBean serverThingsList(@RequestParam Map<String, Object> params, HttpServletRequest request)  throws MyException {
        PageInfo serverThingsList = engineServerService.selectServerThingsList(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", serverThingsList);
    }


    /**
     * 总统计接口
     */
    @GetMapping("/headCount")
    public ResponseBean headCount(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        params.put("sid", getCurrentUser(request).getS_id());
        Map<String, Object> headCount = relationService.headCount(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }

    /**
     * 服务商车辆地图接口
     */
    @GetMapping("/mapForCarServer")
    public ResponseBean mapForCarServer(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        params.put("sid", getCurrentUser(request).getS_id());
        Map<String, Object> headCount = relationService.mapForCarServer(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }

    /**
     * 服务商省车辆地图接口
     */
    @GetMapping("/mapForCarServerByPro")
    public ResponseBean mapForCarServerByPro(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        params.put("sid", getCurrentUser(request).getS_id());
        Map<String, Object> headCount = relationService.mapForCarServerByPro(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }

    /**
     * 服务商省车辆地图接口-服务商
     */
    @GetMapping("/mapForCarServerBySid")
    public ResponseBean mapForCarServerBySid(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        Map<String, Object> headCount = relationService.mapForCarServerBySid(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }

    /**
     * 车辆信息
     */
    @GetMapping("/carInfoByMap")
    public ResponseBean carInfoByMap(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        Map<String, Object> headCount = relationService.carInfoByMap(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }


    /**
     * 车辆详情带oid
     */
    @GetMapping("/carInfoOwner")
    public ResponseBean carInfoOwner(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        Map<String, Object> headCount = relationService.carInfoOwner(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }

    /**
     * 车辆的视频详情
     */
    @PostMapping("/carInfoOwnerVideoInfo")
    public ResponseBean carInfoOwnerVideoInfo(@RequestBody Map<String, Object> params, HttpServletRequest request) throws MyException {
        Map<String, Object> resMap = relationService.carInfoOwnerVideoInfo(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", resMap);
    }

    //服务商列表统计
    @GetMapping("/serverList")
    public ResponseBean serverList(@RequestParam Map<String, Object> params, HttpServletRequest request) throws MyException {
        params.put("sid", getCurrentUser(request).getS_id());
        Map<String, Object> headCount = relationService.serverList(params);
        return new ResponseBean(Constants.CODE_SUCCESS, "操作成功", headCount);
    }


}
